from flask import Flask, send_file, request
from download import main
app = Flask(__name__)


@app.route('/')
def hello():
    steps = int(request.args.get("steps", 10))
    n_samples = int(request.args.get("n_samples", 1))
    replay = request.args.get("replay", None) is not None
    assert steps <= 2048
    assert n_samples == 1 or 1024 <= n_samples <= 65536
    assert steps * n_samples <= 2048 ** 2
    main(steps, n_samples, replay)
    return send_file("plt.jpg")

if __name__ == '__main__':
    app.run()
